/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package opera.view;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import opera.exception.JogoInvalidoException;
import opera.model.Jogo;

/**
 *
 * @author Luciano
 */
public class PnlDeletar extends MoldePaineis {
    
    /**
     * Getters 
     */
    public JButton getBtnCancelar() {
        return btnCancelar;
    }

    public JButton getBtnDeletar() {
        return btnDeletar;
    }

    public JPanel getPnlEquipamento() {
        return pnlEquipamento;
    }

    public JRadioButton getRdbArmaBranca() {
        return rdbArmaBranca;
    }

    public JRadioButton getRdbArmaDeFogo() {
        return rdbArmaDeFogo;
    }

    public JRadioButton getRdbArmadura() {
        return rdbArmadura;
    }

    public JRadioButton getRdbCaracteristica() {
        return rdbCaracteristica;
    }

    public JRadioButton getRdbEquipamento() {
        return rdbEquipamento;
    }

    public JRadioButton getRdbFicha() {
        return rdbFicha;
    }
    
    public JRadioButton getRdbHabilidade() {
        return rdbHabilidade;
    }

    public Jogo getJogo(){
        return jogo;
    }
    
    public final void setJogo(Jogo jogo){
        this.jogo = jogo;
    }

    public JComboBox getCmbSelecionar() {
        return cmbSelecionar;
    }

    public void setCmbSelecionar(JComboBox cmbSelecionar) {
        this.cmbSelecionar = cmbSelecionar;
    }

    public String getEndereco() {
        return endereco;
    }

    public void setEndereco(String endereco) {
        this.endereco = endereco;
    }

    public Object getObjeto() {
        return objeto;
    }

    public void setObjeto(Object objeto) {
        this.objeto = objeto;
    }

    public JPanel getLblFicha() {
        return pnlFicha;
    }

    public void setLblFicha(JPanel lblFicha) {
        this.pnlFicha = lblFicha;
    }

    public JRadioButton getRdbJogador() {
        return rdbJogador;
    }

    public void setRdbJogador(JRadioButton rdbJogador) {
        this.rdbJogador = rdbJogador;
    }

    public JRadioButton getRdbJogo() {
        return rdbJogo;
    }

    public void setRdbJogo(JRadioButton rdbJogo) {
        this.rdbJogo = rdbJogo;
    }

    public JRadioButton getRdbMonstro() {
        return rdbMonstro;
    }

    public void setRdbMonstro(JRadioButton rdbMonstro) {
        this.rdbMonstro = rdbMonstro;
    }

    public JRadioButton getRdbNpc() {
        return rdbNpc;
    }

    public void setRdbNpc(JRadioButton rdbNpc) {
        this.rdbNpc = rdbNpc;
    }
    
    
    
    
    
    /**
     * Creates new form PnlDeletar
     */
    public PnlDeletar(Jogo jogo) {
        initComponents();
        setJogo(jogo);
        carregarCmbSelecionar(jogo, rdbJogador);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grpDeletar = new javax.swing.ButtonGroup();
        grpEquipamento = new javax.swing.ButtonGroup();
        grpFicha = new javax.swing.ButtonGroup();
        pnlDeletar = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        rdbFicha = new javax.swing.JRadioButton();
        rdbHabilidade = new javax.swing.JRadioButton();
        rdbCaracteristica = new javax.swing.JRadioButton();
        rdbEquipamento = new javax.swing.JRadioButton();
        lblSelecionar = new javax.swing.JLabel();
        cmbSelecionar = new javax.swing.JComboBox();
        pnlEquipamento = new javax.swing.JPanel();
        rdbArmaBranca = new javax.swing.JRadioButton();
        rdbArmaDeFogo = new javax.swing.JRadioButton();
        rdbArmadura = new javax.swing.JRadioButton();
        rdbJogo = new javax.swing.JRadioButton();
        pnlFicha = new javax.swing.JPanel();
        rdbJogador = new javax.swing.JRadioButton();
        rdbNpc = new javax.swing.JRadioButton();
        rdbMonstro = new javax.swing.JRadioButton();
        btnCancelar = new javax.swing.JButton();
        btnDeletar = new javax.swing.JButton();

        pnlDeletar.setBorder(javax.swing.BorderFactory.createTitledBorder("Deletar"));

        jLabel1.setText("Selecione o que deseja DELETAR:");

        grpDeletar.add(rdbFicha);
        rdbFicha.setSelected(true);
        rdbFicha.setText("Ficha");
        rdbFicha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbFichaActionPerformed(evt);
            }
        });

        grpDeletar.add(rdbHabilidade);
        rdbHabilidade.setText("Habilidade");
        rdbHabilidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbHabilidadeActionPerformed(evt);
            }
        });

        grpDeletar.add(rdbCaracteristica);
        rdbCaracteristica.setText("Caracteristica");
        rdbCaracteristica.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbCaracteristicaActionPerformed(evt);
            }
        });

        grpDeletar.add(rdbEquipamento);
        rdbEquipamento.setText("Equipamento");
        rdbEquipamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbEquipamentoActionPerformed(evt);
            }
        });

        lblSelecionar.setText("Selecionar Ficha:");

        cmbSelecionar.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbSelecionar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbSelecionarActionPerformed(evt);
            }
        });

        pnlEquipamento.setBorder(javax.swing.BorderFactory.createTitledBorder("Equipamento"));
        pnlEquipamento.setEnabled(false);

        grpEquipamento.add(rdbArmaBranca);
        rdbArmaBranca.setSelected(true);
        rdbArmaBranca.setText("Arma Branca");
        rdbArmaBranca.setEnabled(false);
        rdbArmaBranca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbArmaBrancaActionPerformed(evt);
            }
        });

        grpEquipamento.add(rdbArmaDeFogo);
        rdbArmaDeFogo.setText("Arma de Fogo");
        rdbArmaDeFogo.setEnabled(false);
        rdbArmaDeFogo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbArmaDeFogoActionPerformed(evt);
            }
        });

        grpEquipamento.add(rdbArmadura);
        rdbArmadura.setText("Armadura");
        rdbArmadura.setEnabled(false);
        rdbArmadura.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbArmaduraActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlEquipamentoLayout = new javax.swing.GroupLayout(pnlEquipamento);
        pnlEquipamento.setLayout(pnlEquipamentoLayout);
        pnlEquipamentoLayout.setHorizontalGroup(
            pnlEquipamentoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlEquipamentoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdbArmaBranca)
                .addGap(18, 18, 18)
                .addComponent(rdbArmaDeFogo)
                .addGap(18, 18, 18)
                .addComponent(rdbArmadura)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlEquipamentoLayout.setVerticalGroup(
            pnlEquipamentoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlEquipamentoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlEquipamentoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdbArmaBranca)
                    .addComponent(rdbArmaDeFogo)
                    .addComponent(rdbArmadura))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        grpDeletar.add(rdbJogo);
        rdbJogo.setText("Jogo");
        rdbJogo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbJogoActionPerformed(evt);
            }
        });

        pnlFicha.setBorder(javax.swing.BorderFactory.createTitledBorder("Ficha"));

        grpFicha.add(rdbJogador);
        rdbJogador.setSelected(true);
        rdbJogador.setText("Jogador");
        rdbJogador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbJogadorActionPerformed(evt);
            }
        });

        grpFicha.add(rdbNpc);
        rdbNpc.setText("NPC");
        rdbNpc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbNpcActionPerformed(evt);
            }
        });

        grpFicha.add(rdbMonstro);
        rdbMonstro.setText("Monstro");
        rdbMonstro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rdbMonstroActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlFichaLayout = new javax.swing.GroupLayout(pnlFicha);
        pnlFicha.setLayout(pnlFichaLayout);
        pnlFichaLayout.setHorizontalGroup(
            pnlFichaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlFichaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdbJogador)
                .addGap(18, 18, 18)
                .addComponent(rdbNpc)
                .addGap(18, 18, 18)
                .addComponent(rdbMonstro)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlFichaLayout.setVerticalGroup(
            pnlFichaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlFichaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlFichaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdbJogador)
                    .addComponent(rdbNpc)
                    .addComponent(rdbMonstro))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout pnlDeletarLayout = new javax.swing.GroupLayout(pnlDeletar);
        pnlDeletar.setLayout(pnlDeletarLayout);
        pnlDeletarLayout.setHorizontalGroup(
            pnlDeletarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDeletarLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDeletarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDeletarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(pnlDeletarLayout.createSequentialGroup()
                            .addComponent(rdbFicha)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(rdbHabilidade)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(rdbCaracteristica)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(rdbEquipamento)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(rdbJogo))
                        .addComponent(jLabel1)
                        .addComponent(pnlEquipamento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(pnlFicha, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(pnlDeletarLayout.createSequentialGroup()
                        .addComponent(lblSelecionar)
                        .addGap(18, 18, 18)
                        .addComponent(cmbSelecionar, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlDeletarLayout.setVerticalGroup(
            pnlDeletarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDeletarLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlDeletarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdbFicha)
                    .addComponent(rdbHabilidade)
                    .addComponent(rdbCaracteristica)
                    .addComponent(rdbEquipamento)
                    .addComponent(rdbJogo))
                .addGap(18, 18, 18)
                .addComponent(pnlFicha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(pnlEquipamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(pnlDeletarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblSelecionar)
                    .addComponent(cmbSelecionar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(40, Short.MAX_VALUE))
        );

        btnCancelar.setText("Cancelar");

        btnDeletar.setText("Deletar");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnDeletar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnCancelar))
                    .addComponent(pnlDeletar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(pnlDeletar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancelar)
                    .addComponent(btnDeletar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void rdbFichaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbFichaActionPerformed
        // TODO add your handling code here:
        habilitarPnlEquipamento(false);
        habilitarPnlFicha(true);
        
        if(rdbJogador.isSelected()){
            alterarTextoLblSelecionar(rdbJogador);
            carregarCmbSelecionar(jogo, rdbJogador);
        }
        if(rdbNpc.isSelected()){
            alterarTextoLblSelecionar(rdbNpc);
            carregarCmbSelecionar(jogo, rdbNpc);
        }
        if(rdbMonstro.isSelected()){
            alterarTextoLblSelecionar(rdbMonstro);
            carregarCmbSelecionar(jogo, rdbMonstro);
        }
    }//GEN-LAST:event_rdbFichaActionPerformed

    private void rdbHabilidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbHabilidadeActionPerformed
        // TODO add your handling code here:
        habilitarPnlEquipamento(false);
        habilitarPnlFicha(false);
        alterarTextoLblSelecionar(rdbHabilidade);
        carregarCmbSelecionar(jogo, rdbHabilidade);
    }//GEN-LAST:event_rdbHabilidadeActionPerformed

    private void rdbCaracteristicaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbCaracteristicaActionPerformed
        // TODO add your handling code here:
        habilitarPnlEquipamento(false);
        habilitarPnlFicha(false);
        alterarTextoLblSelecionar(rdbCaracteristica);
        carregarCmbSelecionar(jogo, rdbCaracteristica);
    }//GEN-LAST:event_rdbCaracteristicaActionPerformed

    private void rdbEquipamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbEquipamentoActionPerformed
        // TODO add your handling code here:
        habilitarPnlEquipamento(true);
        habilitarPnlFicha(false);
        //alterarTextoLblSelecionar(rdbEquipamento);
        if(rdbArmaBranca.isSelected()){
            alterarTextoLblSelecionar(rdbArmaBranca);
            carregarCmbSelecionar(jogo, rdbArmaBranca);
        }
        if(rdbArmaDeFogo.isSelected()){
            alterarTextoLblSelecionar(rdbArmaDeFogo);
            carregarCmbSelecionar(jogo, rdbArmaDeFogo);
        }
        if(rdbArmadura.isSelected()){
            alterarTextoLblSelecionar(rdbArmadura);
            carregarCmbSelecionar(jogo, rdbArmadura);
        }
    }//GEN-LAST:event_rdbEquipamentoActionPerformed

    private void rdbJogoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbJogoActionPerformed
        // TODO add your handling code here:
        habilitarPnlEquipamento(false);
        alterarTextoLblSelecionar(rdbJogo);
        carregarCmbSelecionar(jogo, rdbJogo);
    }//GEN-LAST:event_rdbJogoActionPerformed

    private void rdbArmaBrancaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbArmaBrancaActionPerformed
        // TODO add your handling code here:
        alterarTextoLblSelecionar(rdbArmaBranca);
        carregarCmbSelecionar(jogo, rdbArmaBranca);
    }//GEN-LAST:event_rdbArmaBrancaActionPerformed

    private void rdbArmaDeFogoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbArmaDeFogoActionPerformed
        // TODO add your handling code here:
        alterarTextoLblSelecionar(rdbArmaDeFogo);
        carregarCmbSelecionar(jogo, rdbArmaDeFogo);
    }//GEN-LAST:event_rdbArmaDeFogoActionPerformed

    private void rdbArmaduraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbArmaduraActionPerformed
        // TODO add your handling code here:
        alterarTextoLblSelecionar(rdbArmadura);
        carregarCmbSelecionar(jogo, rdbArmadura);
    }//GEN-LAST:event_rdbArmaduraActionPerformed

    private void cmbSelecionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbSelecionarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmbSelecionarActionPerformed

    private void rdbNpcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbNpcActionPerformed
        // TODO add your handling code here:
        alterarTextoLblSelecionar(rdbNpc);
        carregarCmbSelecionar(jogo, rdbNpc);
    }//GEN-LAST:event_rdbNpcActionPerformed

    private void rdbJogadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbJogadorActionPerformed
        // TODO add your handling code here:
        alterarTextoLblSelecionar(rdbJogador);
        carregarCmbSelecionar(jogo, rdbJogador);
    }//GEN-LAST:event_rdbJogadorActionPerformed

    private void rdbMonstroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbMonstroActionPerformed
        // TODO add your handling code here:
        alterarTextoLblSelecionar(rdbMonstro);
        carregarCmbSelecionar(jogo, rdbMonstro);
    }//GEN-LAST:event_rdbMonstroActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnDeletar;
    private javax.swing.JComboBox cmbSelecionar;
    private javax.swing.ButtonGroup grpDeletar;
    private javax.swing.ButtonGroup grpEquipamento;
    private javax.swing.ButtonGroup grpFicha;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel lblSelecionar;
    private javax.swing.JPanel pnlDeletar;
    private javax.swing.JPanel pnlEquipamento;
    private javax.swing.JPanel pnlFicha;
    private javax.swing.JRadioButton rdbArmaBranca;
    private javax.swing.JRadioButton rdbArmaDeFogo;
    private javax.swing.JRadioButton rdbArmadura;
    private javax.swing.JRadioButton rdbCaracteristica;
    private javax.swing.JRadioButton rdbEquipamento;
    private javax.swing.JRadioButton rdbFicha;
    private javax.swing.JRadioButton rdbHabilidade;
    private javax.swing.JRadioButton rdbJogador;
    private javax.swing.JRadioButton rdbJogo;
    private javax.swing.JRadioButton rdbMonstro;
    private javax.swing.JRadioButton rdbNpc;
    // End of variables declaration//GEN-END:variables
    private Jogo jogo;
    //Objeto a ser deletado (ou selecionado)
    private Object objeto;
    private String endereco;
    
    
    
    public void selecionarObjeto() throws IOException, ClassNotFoundException, JogoInvalidoException{
        
        //Object objeto;
        
        String itemSelecionado = cmbSelecionar.getSelectedItem().toString(); 
        
        //System.out.println("rdbJogo.isSelected(): " + rdbJogo.isSelected());
        
        if(!rdbJogo.isSelected()){
            
            if( (itemSelecionado != null) && (!itemSelecionado.equals("")) && (!itemSelecionado.equals(" ")) ){
                String enderecoObjeto = endereco + "\\" + itemSelecionado +".txt";

                FileInputStream fis = new FileInputStream(enderecoObjeto);
                try (ObjectInputStream ois = new ObjectInputStream(fis)) {
                    objeto = ois.readObject();
                }
            }else{
                objeto = null;
            }
            //System.out.println(objeto.toString());
            //return objeto;
        }else{
            Jogo tempJogo = new Jogo(itemSelecionado);
            objeto = tempJogo;
        }
    }


    private void habilitarPnlEquipamento(boolean habilitar){
        pnlEquipamento.setEnabled(habilitar);
        rdbArmaBranca.setEnabled(habilitar);
        rdbArmaDeFogo.setEnabled(habilitar);
        rdbArmadura.setEnabled(habilitar);
    }
    
    private void habilitarPnlFicha(boolean habilitar){
        pnlFicha.setEnabled(habilitar);
        rdbJogador.setEnabled(habilitar);
        rdbNpc.setEnabled(habilitar);
        rdbMonstro.setEnabled(habilitar);
    }
    
    private void alterarTextoLblSelecionar(JRadioButton rdb){
        lblSelecionar.setText("Selecionar " + rdb.getText() + ":");
    }
    
    
    @Override
    public void atualizarJComboBox() {
        JRadioButton rdbSelecionado = (JRadioButton) grpDeletar.getSelection();
        
        if(rdbSelecionado.equals(rdbFicha)){
            rdbSelecionado = (JRadioButton) grpFicha.getSelection();
        }
        if(rdbSelecionado.equals(rdbEquipamento)){
            rdbSelecionado = (JRadioButton) grpEquipamento.getSelection();
        }
        
        carregarCmbSelecionar(getJogo(),rdbSelecionado);
    }
    
    
    public void carregarCmbSelecionar(Jogo jogo, JRadioButton rdb){
        
        String carregar = null;
        
        if(rdb.getText().equals(rdbFicha.getText())){
            if(rdbJogador.isSelected()){
                carregar = "\\Fichas\\Jogador";
            }
            if(rdbNpc.isSelected()){
                carregar = "\\Fichas\\NPC";
            }
            if(rdbMonstro.isSelected()){
                carregar = "\\Fichas\\Monstro";
            }
        }
        if(rdb.getText().equals(rdbJogador.getText())){
            carregar = "\\Fichas\\Jogador";
        }
        if(rdb.getText().equals(rdbNpc.getText())){
            carregar = "\\Fichas\\NPC";
        }
        if(rdb.getText().equals(rdbMonstro.getText())){
            carregar = "\\Fichas\\Monstro";
        }
        if(rdb.getText().equals(rdbHabilidade.getText())){
            carregar = "Habilidades";
        }
        if(rdb.getText().equals(rdbCaracteristica.getText())){
            carregar = "Caracteristicas";
        }
        if(rdb.getText().equals(rdbEquipamento.getText())){
            if(rdbArmaBranca.isSelected()){
                carregar = "\\Equipamentos\\Arma\\Arma Branca";
            }
            if(rdbArmaDeFogo.isSelected()){
                carregar = "\\Equipamentos\\Arma\\Arma de Fogo";
            }
            if(rdbArmadura.isSelected()){
                carregar = "\\Equipamentos\\Armadura";
            }
        }
        if(rdb.getText().equals(rdbArmaBranca.getText())){
            carregar = "\\Equipamentos\\Arma\\Arma Branca";
        }
        if(rdb.getText().equals(rdbArmaDeFogo.getText())){
            carregar = "\\Equipamentos\\Arma\\Arma de Fogo";
        }
        if(rdb.getText().equals(rdbArmadura.getText())){
            carregar = "\\Equipamentos\\Armadura";
        }
        if(rdb.getText().equals(rdbJogo.getText())){
            carregar = "Jogo";
        }
        
        
        
        cmbSelecionar.setModel(new javax.swing.DefaultComboBoxModel(new String[] { ""}));
        File diretorio;
        if(carregar.equals("Jogo")){
            diretorio = new File("C:\\Opera\\Jogos");
        }else{
            //diretorio = new File("C:\\Opera\\Jogos\\" + jogo.getNome() + "\\Fichas");
            diretorio = new File("C:\\Opera\\Jogos\\" + jogo.getNome() + "\\" + carregar);
        }
        
        endereco = diretorio.getAbsolutePath();
        
        if(diretorio.exists()){
            //statusDiretorio = diretorio.mkdir();
            String diretorios[] = diretorio.list();
            for(int i = 0; i < diretorios.length; i++){
                //System.out.println(diretorios[i]);
                String item;
                if(!rdbJogo.isSelected()){
                    item = diretorios[i].substring(0, (diretorios[i].length()-4) );
                }else{
                    item = diretorios[i];
                }
                cmbSelecionar.addItem(item);
            }
        }
    }



}
